package com.zixuan.controller;

import com.zixuan.common.Result;
import com.zixuan.common.dto.DeviceMangerRequestDTO;
import com.zixuan.entity.DeviceMannerEntity;
import com.zixuan.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sys/device")
public class DeviceController {

    @Autowired
    private DeviceService deviceService;

    @PostMapping("/addDevice")
    public Result addDevice(@RequestBody DeviceMannerEntity deviceMannerEntity){
        return deviceService.addDevice(deviceMannerEntity);
    }

    @GetMapping("/findDeviceBy/{id}")
    public Result findDeviceById(@PathVariable("id") String id){
        return deviceService.findDeviceById(id);
    }

    @GetMapping("/findAllDevice/{start}/{end}")
    public Result findAllDevice(@PathVariable("start") String start,@PathVariable("end") String end){
        return deviceService.findAllDevice(start,end);
    }
    /**
     * 根据条件查询设备信息
     */

    @PostMapping("/findDeviceByCondition")
    public Result findDeviceByCondition(@RequestBody DeviceMangerRequestDTO dto){
        return deviceService.findDeviceByCondition(dto);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @DeleteMapping("/delDeviceBy/{id}")
    public Result delDeviceBydIds(@PathVariable("id") String id){
        return deviceService.delDeviceBydIds(id);
    }

    /**
     * 更新设备信息
     * @param deviceMannerEntity
     * @return
     */
    @PutMapping("/updateDevice")
    public Result updateDevice(@RequestBody DeviceMannerEntity deviceMannerEntity){
        return deviceService.updateDevice(deviceMannerEntity);
    }
}
